<?php
class Admin_Form_ValidateProductStock extends Zendvn_Validate_Form{

	public function __construct($arrParam = null, $options = null){
		//================================Validate Unit================================
		$validator = new Zend_Validate();
		$validator->addValidator(new Zend_Validate_NotEmpty(), true);
		if(!$validator->isValid($arrParam['size_id'])){
			$message = $validator->getMessages();
			$this->_arrError['size_id'] = current($message);
			$arrParam['size_id'] = '';
		}
		
		//================================Validate Price================================
		if(!empty($arrParam['stock'])):
			foreach ($arrParam['stock'] as $k => $v):
				$validator = new Zend_Validate();
				$validator->addValidator(new Zend_Validate_NotEmpty(), true);
				if(!$validator->isValid($arrParam['stock'][$k])){
					$message = $validator->getMessages();
					$this->_arrError['stock'][$k] = current($message);
					$arrParam['stock'][$k] = '';
				}
			endforeach;
		endif;
		
		$this->_arrData = $arrParam;
	}
	
	public function getData(){
		return $this->_arrData;
	}
	public function isVaild(){
		$flag = false;
		if(count($this->_arrError) > 0 && $this->_arrError != ''){
			$flag = true;
		}
		return $flag;
	}
	
	public function getMessageErrors(){
		return $this->_arrError;
	}
	
}







